home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Misc Servers / Zope.exe / PROPERTYSHEET.PY < prev    next >
Encoding:
Text File  |  2000-10-31  |  9.9 KB  |  300 lines

  1. ##############################################################################
  2. # Zope Public License (ZPL) Version 1.0
  3. # -------------------------------------
  4. # Copyright (c) Digital Creations.  All rights reserved.
  5. # This license has been certified as Open Source(tm).
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions are
  8. # met:
  9. # 1. Redistributions in source code must retain the above copyright
  10. #    notice, this list of conditions, and the following disclaimer.
  11. # 2. Redistributions in binary form must reproduce the above copyright
  12. #    notice, this list of conditions, and the following disclaimer in
  13. #    the documentation and/or other materials provided with the
  14. #    distribution.
  15. # 3. Digital Creations requests that attribution be given to Zope
  16. #    in any manner possible. Zope includes a "Powered by Zope"
  17. #    button that is installed by default. While it is not a license
  18. #    violation to remove this button, it is requested that the
  19. #    attribution remain. A significant investment has been put
  20. #    into Zope, and this effort will continue if the Zope community
  21. #    continues to grow. This is one way to assure that growth.
  22. # 4. All advertising materials and documentation mentioning
  23. #    features derived from or use of this software must display
  24. #    the following acknowledgement:
  25. #      "This product includes software developed by Digital Creations
  26. #      for use in the Z Object Publishing Environment
  27. #      (http://www.zope.org/)."
  28. #    In the event that the product being advertised includes an
  29. #    intact Zope distribution (with copyright and license included)
  30. #    then this clause is waived.
  31. # 5. Names associated with Zope or Digital Creations must not be used to
  32. #    endorse or promote products derived from this software without
  33. #    prior written permission from Digital Creations.
  34. # 6. Modified redistributions of any form whatsoever must retain
  35. #    the following acknowledgment:
  36. #      "This product includes software developed by Digital Creations
  37. #      for use in the Z Object Publishing Environment
  38. #      (http://www.zope.org/)."
  39. #    Intact (re-)distributions of any official Zope release do not
  40. #    require an external acknowledgement.
  41. # 7. Modifications are encouraged but must be packaged separately as
  42. #    patches to official Zope releases.  Distributions that do not
  43. #    clearly separate the patches from the original work must be clearly
  44. #    labeled as unofficial distributions.  Modifications which do not
  45. #    carry the name Zope may be packaged in any form, as long as they
  46. #    conform to all of the clauses above.
  47. # Disclaimer
  48. #   THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS ``AS IS'' AND ANY
  49. #   EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  50. #   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  51. #   PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL DIGITAL CREATIONS OR ITS
  52. #   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  53. #   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  54. #   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  55. #   USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  56. #   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  57. #   OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  58. #   OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  59. #   SUCH DAMAGE.
  60. # This software consists of contributions made by Digital Creations and
  61. # many individuals on behalf of Digital Creations.  Specific
  62. # attributions are listed in the accompanying credits file.
  63. ##############################################################################
  64.  
  65. class PropertySheet:
  66.     """
  67.  
  68.     A PropertySheet is an abstraction for organizing and working
  69.     with a set of related properties. Conceptually it acts like a
  70.     container for a set of related properties and meta-data describing 
  71.     those properties. A PropertySheet may or may not provide a web 
  72.     interface for managing its properties.
  73.  
  74.     """
  75.  
  76.     def xml_namespace():
  77.         """
  78.  
  79.         Return a namespace string usable as an xml namespace
  80.         for this property set. This may be an empty string if 
  81.         there is no default namespace for a given property sheet
  82.         (especially property sheets added in ZClass definitions).
  83.  
  84.         Permission -- Python only
  85.  
  86.         """
  87.  
  88.     def getProperty(id, d=None):
  89.         """
  90.  
  91.         Get the property 'id', returning the optional second 
  92.         argument or None if no such property is found.
  93.  
  94.         Permission -- Python only
  95.         
  96.         """
  97.  
  98.     def getPropertyType(id):
  99.         """
  100.         
  101.         Get the type of property 'id'. Returns None if no such
  102.         property exists.
  103.  
  104.         Permission -- Python only
  105.         
  106.         """
  107.  
  108.     def hasProperty(id):
  109.         """
  110.  
  111.         Returns true if 'self' has a property with the given 'id', 
  112.         false otherwise.
  113.  
  114.         Permission -- 'Access contents information'
  115.  
  116.         """
  117.  
  118.     def propertyIds():
  119.         """
  120.  
  121.         Returns a list of property ids.
  122.  
  123.         Permission --  'Access contents information'
  124.  
  125.         """
  126.  
  127.     def propertyValues():
  128.         """
  129.  
  130.         Returns a list of actual property values.
  131.  
  132.         Permission -- 'Access contents information'
  133.  
  134.         """
  135.  
  136.     def propertyItems():
  137.         """
  138.  
  139.         Return a list of (id, property) tuples.
  140.  
  141.         Permission -- 'Access contents information'
  142.  
  143.         """
  144.         
  145.     def propertyMap():
  146.         """
  147.  
  148.         Returns a tuple of mappings, giving meta-data for properties.
  149.  
  150.         Perimssion -- Python only
  151.  
  152.         """
  153.  
  154.     def propertyInfo():
  155.         """
  156.  
  157.         Returns a mapping containing property meta-data.
  158.  
  159.         Permission -- Python only
  160.  
  161.         """
  162.  
  163.     def manage_addProperty(id, value, type, REQUEST=None):
  164.         """
  165.  
  166.         Add a new property with the given 'id', 'value' and 'type'.
  167.  
  168.         Property Types
  169.  
  170.           'boolean' -- 1 or 0. 
  171.  
  172.           'date' -- A 'DateTime' value, for example '12/31/1999 15:42:52 PST'.
  173.  
  174.           'float' -- A decimal number, for example '12.4'. 
  175.  
  176.           'int' -- An integer number, for example, '12'. 
  177.  
  178.           'lines' -- A list of strings, one per line. 
  179.  
  180.           'long' -- A long integer, for example '12232322322323232323423'. 
  181.  
  182.           'string' -- A string of characters, for example 'This is a string'. 
  183.  
  184.           'text' -- A multi-line string, for example a paragraph. 
  185.  
  186.           'tokens' -- A list of strings separated by white space, for example
  187.           'one two three'. 
  188.  
  189.           'selection' -- A string selected by a pop-up menu. 
  190.  
  191.           'multiple selection' -- A list of strings selected by a selection list.
  192.  
  193.         This method will use the passed in 'type' to try to convert
  194.         the 'value' argument to the named type. If the given 'value'
  195.         cannot be converted, a ValueError will be raised.
  196.  
  197.         The value given for 'selection' and 'multiple selection'
  198.         properites must be a variable name.  The variable must also be
  199.         a sequence.
  200.  
  201.         *If the given 'type' is not recognized, the 'value' and 'type'
  202.         given are simply stored blindly by the object. This seems like
  203.         bad behavior - it should probably raise an exception instead.*
  204.  
  205.         If no value is passed in for 'REQUEST', the method will return
  206.         'None'. If a value is provided for 'REQUEST' (as it will when
  207.         called via the web), the property management form for the
  208.         object will be rendered and returned.
  209.  
  210.         This method may be called via the web, from DTML or from
  211.         Python code.
  212.  
  213.         Permission -- 'Manage Properties'
  214.  
  215.         """
  216.  
  217.     def manage_changeProperties(REQUEST=None, **kw):
  218.         """
  219.  
  220.         Change existing object properties by passing either a mapping 
  221.         object as 'REQUEST' containing name:value pairs or by passing 
  222.         name=value keyword arguments.
  223.  
  224.         Some objects have "special" properties defined by product 
  225.         authors that cannot be changed. If you try to change one of 
  226.         these properties through this method, an error will be raised.
  227.  
  228.         Note that no type checking or conversion happens when this 
  229.         method is called, so it is the caller's responsibility to 
  230.         ensure that the updated values are of the correct type. 
  231.         *This should probably change*.
  232.  
  233.         If a value is provided for 'REQUEST' (as it will be when
  234.         called via the web), the method will return an HTML message
  235.         dialog. If no REQUEST is passed, the method returns 'None' on
  236.         success.
  237.  
  238.         This method may be called via the web, from DTML or from
  239.         Python code.
  240.  
  241.         Permission - 'Manage Properties'
  242.  
  243.         """
  244.  
  245.  
  246.     def manage_delProperties(ids=None, REQUEST=None):
  247.         """
  248.  
  249.         Delete one or more properties with the given 'ids'. The 'ids' 
  250.         argument should be a sequence (tuple or list) containing the 
  251.         ids of the properties to be deleted. If 'ids' is empty no 
  252.         action will be taken. If any of the properties named in 'ids' 
  253.         does not exist, an error will be raised. 
  254.  
  255.         Some objects have "special" properties defined by product
  256.         authors that cannot be deleted. If one of these properties is
  257.         named in 'ids', an HTML error message is returned (this is
  258.         lame and should be changed).
  259.  
  260.         If no value is passed in for 'REQUEST', the method will return
  261.         None. If a value is provided for 'REQUEST' (as it will be when
  262.         
  263.         called via the web), the property management form for the
  264.         object will be rendered and returned.
  265.  
  266.         This method may be called via the web, from DTML or from
  267.         Python code.
  268.  
  269.         Permission - 'Manage Properties'
  270.  
  271.         """
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.